package grupb.upf.imageProcessing;

import java.awt.image.renderable.ParameterBlock;
import javax.media.jai.JAI;
import javax.media.jai.KernelJAI;
import javax.media.jai.PlanarImage;

public class Sharp {

    public PlanarImage execute(final PlanarImage img) {
        final float[] sharpenMoreData =
            {-1.0F / 4.0F, -1.0F / 4.0F, -1.0F / 4.0F,
            -1.0F / 4.0F, 12.0F / 4.0F, -1.0F / 4.0F,
            -1.0F / 4.0F, -1.0F / 4.0F, -1.0F / 4.0F};

        final KernelJAI kernels = new KernelJAI(3, 3, 1, 1, sharpenMoreData);
        final ParameterBlock paramBlock = new ParameterBlock();
        paramBlock.addSource(img);
        paramBlock.add(kernels);
        final PlanarImage image = JAI.create("convolve", paramBlock);
        return image;
    }
}
